######################################
# Replication data for
# Braumoeller, Bear F., "Guarding Against False Positives in
# Qualitative Comparative Analysis," Political Analysis, forthcoming
######################################


######################################
# Ragin social-revolutions analysis
######################################

library(QCAfalsePositive)
# data(social.revolutions)  # If using data included in QCAfalsePositive

soc.rev <- c(.10,.34,.13,.10,.04,.11,.49,.81,.76,.35,.47,.28,.81,.39,.72,.10,.22,.46,.54,.28)

breakdown <- c(.41,.69,.72,.78,.15,.36,.54,.85,.93,.36,1,1,.81,.69,.82,.54,.25,.48,.86,.73)

pop.ins <- c(.83,.42,.71,.34,.47,.15,.69,.95,.98,.65,.75,.35,.85,.5,.85,.15,.38,.54,.86,.39)

social.revolutions <- data.frame(soc.rev, breakdown, pop.ins)
attach(social.revolutions)

intersect <- pmin(breakdown, pop.ins)
intersect2 <- pmin(breakdown, (1-pop.ins))
intersect3 <- pmin((1-breakdown), pop.ins)
intersect4 <- pmin((1-breakdown), (1-pop.ins))

test <- fsQCApermTest(y=soc.rev, configs=list(BI=intersect, Bi=intersect2,
   bI=intersect3, bi=intersect4), total.configs=4, num.iter=100000, my.seed=123)
summary(test)
test$result.cex[,4:5]
test$result.con[,4:5]
plot(test, "BI", statistic="both")
detach(social.revolutions)


######################################
# Hussain-Howard Arab Spring analysis
######################################

# data(Arab.Spring)   # If using data included in QCAfalsePositive
Arab.Spring <- read.csv("HussainHoward13.csv", row.names=1)
attach(Arab.Spring)

combo.1 <- pmin(Pol, (1-Fuel), (1-Mobile), (1-Unemp))
combo.2 <- pmin((1-Fuel), (1-Youth))
combo.3 <- pmin((1-Fuel), Internet, (1-Unemp))
combo.4 <- pmin((1-Fuel), Internet, Gini)

test2 <- fsQCApermTest(y=Success, configs=list(Pfmu=combo.1, fy=combo.2,
   Ifu=combo.3, IfG=combo.4), total.configs=15, num.iter=100000, my.seed=123)
summary(test2)
plot(test2)
detach(Arab.Spring)

